package com.example.demo.Repository;


import com.example.demo.Entity.Node;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface NodeRepository extends Neo4jRepository<Node,Long> {
    @Query("MATCH p=(n:Person) RETURN p")
    List<Node> selectAll();

    @Query("MATCH (m:Disease) where m.name = $ids return m.cause")
    String findCauseByDisease(@Param("ids")String disease);

    @Query("MATCH (m:Disease) where m.name = $ids return m.prevent")
    String findPreventByDisease(@Param("ids")String disease);

    @Query("MATCH (m:Disease)-[r:do_eat]->(n:Food) where m.name = $ids return n.name")
    String[] DiseaseDoEat(@Param("ids")String disease);

    @Query("MATCH (m:Disease)-[r:belongs_to]->(n:Department) where m.name = $ids return n.name")
    String[] DiseaseCategory(@Param("ids")String disease);

    @Query("MATCH(p:Person{name:{name}}) return p")
    Node findByName(String name);
}
